import { Story } from "../index.stories";
import Table from "..";
// import { Table } from "../../../../dist/index.esm";
import { useState } from "react";
import { IColumnsType } from "../useColumns";
const columns: IColumnsType = [
    {
        title: "序号",
        key: "index",
        render: (t, r, index) => index + 1,
    },
    {
        title: "名称",
        key: "name",
        dataIndex: "name",
        isDisplay: false,
    },
];
const AddAndDelComp = (args: any) => {
    const { isAdd, isDel } = args;
    const [dataSource, setDataSource]: any[] = useState<any>([
        {
            index: "1",
            name: "张三",
        },
        {
            index: "2",
            name: "李四",
        },
    ]);
    const onTableChange = (dataSource: any) => {
        setDataSource(dataSource);
    };

    return (
        <Table
            rowKey="index"
            defaultRowKey="index"
            isAdd={isAdd}
            isDel={isDel}
            columns={columns}
            dataSource={dataSource}
            onTableChange={onTableChange}
            addCallback={() => {}}
        />
    );
};

export const AddAndDel: Story = {
    name: "添加删除组件",
    argTypes: {
        isAdd: {
            control: "boolean",
            description: "设置是否添加",
        },
        isDel: {
            control: "boolean",
            description: "设置是否删除",
        },
    },
    args: {
        isAdd: true,
        isDel: true,
    },
    render: AddAndDelComp,
};
